package system;

import java.io.Serializable;

import api.TaskBase;
/**
 * Wrapper class for the task passed in by the client.
 * This class will be used by Master process for processing
 * sub tasks during mapping/reduction
 *  
 * @author Mayuri Karra, Bing Wei
 *
 */
public class MasterTaskBase implements Serializable{
	private static final long serialVersionUID = 1L;
	// id for client task
	long taskId;
	// id for mapper task or reducer task
	long subTaskId;
	// type of the task
	public static int MAPPER = 0;
	public static int COMBINER = 1;
	public static int REDUCER = 2;
	public static int LOOKUP = 3;
	
	// the actual client task
	TaskBase clientTask;
	// indexes to indicate the partition of a file
	// intended for a given sub task
	int indexLow;
	int indexHigh;
	int type;
	String lookupKey;
	int numSubTasks;

	public MasterTaskBase(long taskId, long subTaskId, TaskBase clientTask, int indexLow,
			int indexHigh, int type, int numSubTasks) {
		super();
		this.taskId = taskId;
		this.subTaskId = subTaskId;
		this.clientTask = clientTask;
		this.indexLow = indexLow;
		this.indexHigh = indexHigh;
		this.type = type;
		this.numSubTasks = numSubTasks;
	}
	
	public MasterTaskBase(long taskId, long subTaskId, TaskBase clientTask, int indexLow,
			int indexHigh, int type, String key, int numSubTasks) {
		super();
		this.taskId = taskId;
		this.subTaskId = subTaskId;
		this.clientTask = clientTask;
		this.indexLow = indexLow;
		this.indexHigh = indexHigh;
		this.type = type;
		this.lookupKey = key;
		this.numSubTasks = numSubTasks;
	}
	
	/**
	 * getter function for lookup key
	 * @return key
	 */
	public String getLookupKey(){
		return lookupKey;
	}

	
	/**
	 * getter function for type
	 * @return type
	 */
	public int getType() {
		return type;
	}

	
	/**
	 * getter function for number of sub tasks
	 * @return number of sub tasks
	 */
	public int getNumSubTasks() {
		return numSubTasks;
	}

	
	/**
	 * getter function for subTaskId
	 * @return sub task id
	 */
	public long getSubTaskId() {
		return subTaskId;
	}

	
	/**
	 * getter function for taskId
	 * @return task id
	 */
	public long getTaskId() {
		return taskId;
	}

	/**
	 * setter function for taskId
	 * @param taskId
	 */
	public void setTaskId(long taskId) {
		this.taskId = taskId;
	}

	/**
	 * getter function for clientTask
	 * @return clientTask
	 */
	public TaskBase getClientTask() {
		return clientTask;
	}

	/**
	 * getter function for indexLow (used by Mapper)
	 * @return indexLow
	 */

	public int getIndexLow() {
		return indexLow;
	}

	/**
	 * getter function for indexHigh (used by Mapper)
	 * @return indexHigh
	 */

	public int getIndexHigh() {
		return indexHigh;
	}

}
